package org.blame;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Set;

public class JedisDemoSet {
    public static void main(String[] args) {
        JedisPool jedisPool=new JedisPool("tcp://127.0.0.1:8888");
        try(Jedis jedis=jedisPool.getResource()){
//            test1(jedis);
//            test2(jedis);
//            test3(jedis);
            test4(jedis);
        }
    }public static void test4(Jedis jedis){
        jedis.flushAll();
        jedis.sadd("k","111","222","333");
        jedis.sadd("k2","333","222","888");
        Set<String> sinter = jedis.sinter("k", "k2");
        System.out.println(sinter);
        long sinterstore = jedis.sinterstore("kk", "k", "k2");
        System.out.println(sinterstore);
        System.out.println(jedis.smembers("kk"));
    }
    public static void test3(Jedis jedis){

    }
    public static void test2(Jedis jedis){
        jedis.flushAll();
        jedis.sadd("k","111","222","333");
        String k = jedis.spop("k");
        System.out.println(k);
    }
    public static void test1(Jedis jedis){
        jedis.flushAll();
        jedis.sadd("k","111","222","333");
        Set<String> k = jedis.smembers("k");
        System.out.println(k);

        boolean k1 = jedis.sismember("k", "111");
        System.out.println(k1);
        long k11 = jedis.scard("k");
        System.out.println(k11);
    }
}
